import {defineStore} from "pinia";

export const useTabStore = defineStore("Tab", {
    state: () => {
        return {
            // 管理标签页数据
            tabList: [{path: "/dashboard/analysis", title: "分析页", open: "1", select: "2"}],
        }
    },
    getters: {
        getAddTab(tabList) {
            return tabList;
        }
    },
    actions: {
        addTab(state, tab) {
            const isSome = state.some(item => item.path === tab.path);
            if (!isSome) {
                state.push(tab);
            }
        }
    },
    persist: {
        enabled: true,
        strategies: [{
            key: "tabList",
            storage: sessionStorage
        }]
    }
});
